﻿using System;
using System.Collections.Generic;
using JetBrains.Annotations;

namespace com.susi.util.toolkit {
    public class ComparerAdapter<T> : System.Collections.Generic.Comparer<T> {
        [NotNull] private Func<T, T, int> Compartor;

        public ComparerAdapter([NotNull] Func<T, T, int> compartor)
        {
            Compartor = compartor ?? throw new ArgumentNullException(nameof(compartor));
        }

        public override int Compare(T x, T y)
        {
            return Compartor(x, y);
        }
    }
}